<template>
  <div id="app">
    <el-container>
      <!--    侧边栏  -->
      <el-aside :width="asideWidth" style="min-height: 100vh; background-color: #001529">
        <div style="height: 60px; color: white; display: flex; align-items: center; justify-content: center">
          <span class="logo-title" v-show="!isCollapse">口腔诊所管理系统</span>
        </div>

        <el-menu :collapse="isCollapse" :collapse-transition="false" router background-color="#001529"
                 text-color="rgba(255, 255, 255, 0.65)" active-text-color="#fff"
                 style="border: none" :default-active="$route.path">
          <el-menu-item index="/home">
            <i class="el-icon-house"></i>
            <span slot="title">系统首页</span>
          </el-menu-item>
          <el-menu-item index="/Patient">
            <i class="el-icon-menu"></i>
            <span slot="title">患者管理</span>
          </el-menu-item>

          <el-submenu index="/2">
            <template slot="title">
              <i class="el-icon-menu"></i>
              <span>预约管理</span>
            </template>
            <el-menu-item index="/Appointment2">预约信息</el-menu-item>
            <el-menu-item index="/Doctor">医生排班信息</el-menu-item>
          </el-submenu>

          <el-submenu index="/3">
            <template slot="title">
              <i class="el-icon-menu"></i>
              <span>治疗管理</span>
            </template>
            <el-menu-item index="/Treatment">治疗计划</el-menu-item>
            <el-menu-item index="/Treatment2">治疗信息</el-menu-item>
          </el-submenu>

          <el-submenu index="/4" v-if="user.role==='管理员'">
            <template slot="title">
              <i class="el-icon-menu"></i>
              <span>财务管理</span>
            </template>
            <el-menu-item index="/Financial">财务信息</el-menu-item>
            <el-menu-item index="/Financial2">财务分析</el-menu-item>
          </el-submenu>

          <el-submenu index="/5" v-if="user.role==='管理员'">
            <template slot="title">
              <i class="el-icon-menu"></i>
              <span>库存管理</span>
            </template>
            <el-menu-item index="/Inventory">库存信息</el-menu-item>
            <el-menu-item index="/Inventory2">库存提醒</el-menu-item>
            <el-menu-item index="/Inventory3">库存采购</el-menu-item>
          </el-submenu>
          <el-submenu index="/6" v-if="user.role==='管理员'">
            <template slot="title">
              <i class="el-icon-menu"></i>
              <span>权限管理</span>
            </template>
            <el-menu-item index="/Account">账号信息管理</el-menu-item>
          </el-submenu>
          <!--          <el-submenu>-->
          <!--            <template slot="title">-->
          <!--              <i class="el-icon-menu"></i>-->
          <!--              <span>功能管理</span>-->
          <!--            </template>-->
          <!--            <el-menu-item>患者管理</el-menu-item>-->
          <!--            <el-menu-item>预约管理</el-menu-item>-->
          <!--            <el-menu-item>治疗管理</el-menu-item>-->
          <!--            <el-menu-item>财务管理</el-menu-item>-->
          <!--            <el-menu-item index="/inventory">库存管理</el-menu-item>-->
          <!--            <el-menu-item>权限管理</el-menu-item>-->
          <!--          </el-submenu>-->

        </el-menu>

      </el-aside>

      <el-container>
        <!--        头部区域-->
        <el-header>
          <div style="flex: 1; width: 0; display: flex; align-items: center; justify-content: flex-end">
            <i class="el-icon-quanping" style="font-size: 26px" @click="handleFull"></i>
            <el-dropdown placement="bottom">
              <div style="display: flex; align-items: center; cursor: default">
<!--                <img src="@/assets/logo.png" alt="" style="width: 40px; height: 40px; margin: 0 5px">-->
                <el-avatar icon="el-icon-user-solid" style="width: 40px; height: 40px; margin: 0 5px"></el-avatar>
                <span>{{ username }}</span>
              </div>
              <el-dropdown-menu slot="dropdown">
<!--                <el-dropdown-item @click.native="$router.push('/Person')">个人信息</el-dropdown-item>-->
<!--                <el-dropdown-item @click="">修改密码</el-dropdown-item>-->
                <el-dropdown-item @click.native="$router.push('/login1')">退出登录</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
        </el-header>

        <!--        主体区域-->
        <el-main style="display: flex; justify-content: center; align-items: center;">
          <router-view></router-view>

        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>

import axios from "axios";

export default {
  name: 'HomeView',
  data() {
    return {
      isCollapse: false,  // 不收缩
      asideWidth: '200px',
      collapseIcon: 'el-icon-s-fold',
        username: '',
        user:JSON.parse(localStorage.getItem('userData')) || {}
    }
  },
  methods: {
    handleFull() {
      document.documentElement.requestFullscreen()
    },
  },
    created() {
        this.username = this.user.name || '';
    },


}

</script>

<style>
.el-menu--inline {
  background-color: #000c17 !important;
}
.el-menu--inline .el-menu-item {
  background-color: #000c17 !important;
  padding-left: 49px !important;
}
.el-menu-item:hover, .el-submenu__title:hover {
  color: #fff !important;
}
.el-submenu__title:hover i {
  color: #fff !important;
}
.el-menu-item:hover i {
  color: #fff !important;
}
.el-menu-item.is-active {
  background-color: #1890ff !important;
  border-radius: 5px !important;
  width: calc(100% - 8px);
  margin-left: 4px;
}
.el-menu-item.is-active i, .el-menu-item.is-active .el-tooltip{
  margin-left: -4px;
}
.el-menu-item {
  height: 40px !important;
  line-height: 40px !important;
}
.el-submenu__title {
  height: 40px !important;
  line-height: 40px !important;
}
.el-submenu .el-menu-item {
  min-width: 0 !important;
}
.el-menu--inline .el-menu-item.is-active {
  padding-left: 45px !important;
}
.el-aside {
  transition: width .3s;
  box-shadow: 2px 0 6px rgba(0,21,41,.35);
}
.logo-title {
  margin-left: 5px;
  font-size: 20px;
  transition: all .3s;   /* 0.3s */
}
.el-header {
  box-shadow: 2px 0 6px rgba(0,21,41,.35);
  display: flex;
  align-items: center;
}
</style>